home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / AMISL092.ZIP / AMIPOPUP.MAC < prev    next >
Encoding:
Text File  |  1993-02-23  |  6.3 KB  |  274 lines

  1. .XLIST
  2. ;-----------------------------------------------------------------------
  3. ; Alternate Multiplex Interrupt Specification Library
  4. ; AMIPOPUP.MAC    Public Domain 1992, 1993 Ralf Brown
  5. ;        You may do with this software whatever you want, but
  6. ;        common courtesy dictates that you not remove my name
  7. ;        from it.
  8. ;
  9. ; Version 0.92
  10. ; LastEdit: 2/21/93
  11. ;-----------------------------------------------------------------------
  12.  
  13.  
  14. ;-----------------------------------------------------------------------
  15.  
  16. PUT_CHAR MACRO ch
  17. TSRcode@
  18. extrn TSR_PUT_CHAR:near
  19. TSRcodeEnd@
  20.  
  21. IFNB <ch>
  22.     mov    al,ch
  23. ENDIF
  24.     call    TSR_PUT_CHAR
  25.     ENDM
  26.  
  27. ;-----------------------------------------------------------------------
  28.  
  29. HOME_CURSOR MACRO
  30. TSRcode@
  31. extrn TSR_HOME_CURSOR:near
  32. TSRcodeEnd@
  33.     call    TSR_HOME_CURSOR
  34.     ENDM
  35.  
  36. ;-----------------------------------------------------------------------
  37.  
  38. MOVE_CURSOR MACRO row,col,rowcol
  39. TSRcode@
  40. extrn TSR_MOVE_CURSOR:near
  41. TSRcodeEnd@
  42. IFNB <row>
  43.     mov    dh,row
  44. ENDIF
  45. IFNB <col>
  46.     mov    dl,col
  47. ENDIF
  48. IFNB <rowcol>
  49.     mov    dx,rowcol
  50. ENDIF
  51.     CALL    TSR_MOVE_CURSOR
  52.     ENDM
  53.  
  54. ;-----------------------------------------------------------------------
  55.  
  56. GETKEY MACRO
  57. TSRcode@
  58. extrn TSR_GETKEY:near
  59. TSRcodeEnd@
  60.  
  61.     CALL    TSR_GETKEY
  62.     ENDM
  63.  
  64. ;-----------------------------------------------------------------------
  65.  
  66. PUT_LINE MACRO ch,count
  67. TSRcode@
  68. extrn TSR_PUT_LINE:near
  69. TSRcodeEnd@
  70.  
  71. IFNB <ch>
  72.     mov    al,ch
  73. ENDIF
  74. IFNB <count>
  75.     mov    cx,count
  76. ENDIF
  77.     call    TSR_PUT_LINE
  78.     ENDM
  79.  
  80. ;-----------------------------------------------------------------------
  81.  
  82. CLEAR_WINDOW MACRO
  83. TSRcode@
  84. extrn TSR_CLEAR_WINDOW:near
  85. TSRcodeEnd@
  86.  
  87.     call    TSR_CLEAR_WINDOW
  88.     ENDM
  89.  
  90. ;-----------------------------------------------------------------------
  91.  
  92. SCROLL_WINDOW MACRO
  93. TSRcode@
  94. extrn TSR_SCROLL_WINDOW:near
  95. TSRcodeEnd@
  96.  
  97.     call    TSR_SCROLL_WINDOW
  98.     ENDM
  99.  
  100. ;-----------------------------------------------------------------------
  101.  
  102. SET_WINDOW MACRO row,col,height,width,buffer,name
  103. IFNB <row>
  104.     mov    ah,row
  105. ENDIF
  106. IFNB <col>
  107.     mov    al,col
  108. ENDIF
  109. IFNB <height>
  110.     mov    bh,height
  111. ENDIF
  112. IFNB <width>
  113.     mov    bl,width
  114. ENDIF
  115. IFNB <buffer>
  116.     mov    cx,offset buffer
  117. ENDIF
  118. IFNB <name>
  119.     mov    dx,offset name
  120. ENDIF
  121.     extrn    TSR_SET_WINDOW:DIST
  122.     call    TSR_SET_WINDOW
  123.     ENDM
  124.  
  125. ;-----------------------------------------------------------------------
  126. ; If we can't pop up immediately because DOS or disk I/O is busy, try to pop
  127. ; up on a subsequent timer tick
  128. ;
  129. DEFAULT_INT08 MACRO
  130. int08_handler proc far
  131. ISP_HEADER 08h
  132.     ASSUME    DS:NOTHING,ES:NOTHING,SS:NOTHING
  133.     pushf
  134.     call    ORIG_INT08h        ; chain to previous handler
  135.     extrn    $AMIS$TRY_POPUP:near
  136.     call    $AMIS$TRY_POPUP        ; if need to pop up, try to do so now
  137.     iret
  138. int08_handler endp
  139.     ENDM
  140.  
  141. ;-----------------------------------------------------------------------
  142. ; Can't pop up when disk is busy, so try to pop up on return
  143. ;
  144. DEFAULT_INT13 MACRO
  145. int13_handler proc far
  146. ISP_HEADER 13h
  147.     ASSUME    DS:NOTHING,ES:NOTHING,SS:NOTHING
  148.     sti                ; OK to interrupt here
  149.     inc    $AMIS$DISK_BUSY
  150.     push    bp            ; now, restore original state of flags,
  151.     mov    bp,sp            ;   especially IF
  152.     push    word ptr [bp+6]        ; original flags before INT 13h
  153.     popf                ; restore original flags
  154.     pop    bp
  155.     pushf                ; simulate INT 13h
  156.     call    ORIG_INT13h
  157.     pushf                ; preserve returned flags
  158.     dec    $AMIS$DISK_BUSY
  159.     popf                ; restore returned flags
  160.     extrn    $AMIS$TRY_POPUP:near
  161.     call    $AMIS$TRY_POPUP        ; pop up if requested (saves all regs)
  162.     ret    2
  163. int13_handler endp
  164.     ENDM
  165.  
  166. ;-----------------------------------------------------------------------
  167. ; Default hotkey checker.
  168. ;
  169. DEFAULT_INT15 MACRO scan,shift
  170.     extrn    $AMIS$ATTEMP_POPUP:near
  171. IFDEF CUSTOM_HOTKEY_CODE
  172. int15_handler proc far
  173. ISP_HEADER 15h
  174.     ASSUME    DS:NOTHING,ES:NOTHING,SS:NOTHING
  175.     pushf
  176.     sti                ; OK to be interrupted
  177.     cmp    ax,4F00h+scan        ; can also patch with actual scan code
  178. hotkey_scancode equ byte ptr ($-2)    ;   at installation time
  179.     jne    not_hotkey
  180.     cmp    TSR_activated,0
  181.     jne    not_hotkey        ; ignore hotkey if already popped up
  182.     push    ds
  183.     push    ax
  184.     xor    ax,ax
  185.     mov    ds,ax
  186.     mov    al,ds:[417h]        ; get shift states
  187.     and    al,0Fh            ; mask out all but Shift/Ctrl/Alt
  188.     cmp    al,shift        ; specified combo of shift keys pressed?
  189.     pop    ax
  190.     pop    ds
  191.     jne    not_hotkey
  192.     ;
  193.     ; yes, we got our hotkey
  194.     ;
  195.     popf
  196.     call    $AMIS$ATTEMPT_POPUP    ; request a popup (preserves flags)
  197.     clc                ; throw out scan code
  198.     ret    2            ; and return so nobody else acts on it
  199. not_hotkey:
  200.     popf                ; restore flags
  201.     jmp    ORIG_INT15h
  202. int15_handler endp
  203.  
  204. ELSE
  205. hotkey_funcs label word            ; list of hotkey handlers
  206.     dw    $AMIS$ATTEMPT_POPUP
  207.  
  208.     HOTKEY_DISPATCHER AFTER,hotkey_funcs
  209. ENDIF
  210.     ENDM
  211.  
  212. ;-----------------------------------------------------------------------
  213. ; Can't pop up when DOS is busy, but can do so during an INT 28h
  214. ;
  215. DEFAULT_INT28 MACRO
  216. int28_handler proc far
  217. ISP_HEADER 28h
  218.     pushf
  219.     inc    $AMIS$POPUP_INT28
  220.     extrn    $AMIS$TRY_POPUP:near
  221.     call    $AMIS$TRY_POPUP
  222.     dec    $AMIS$POPUP_INT28
  223.     popf                ; restore flags before chaining
  224.     jmp    ORIG_INT28h
  225. int28_handler endp
  226.     ENDM
  227.     
  228. ;-----------------------------------------------------------------------
  229.  
  230. DEFAULT_API_POPUP MACRO
  231. API_popup proc near
  232.     ASSUME    DS:NOTHING,ES:NOTHING,SS:NOTHING
  233.     extrn    $AMIS$ATTEMPT_POPUP:near
  234.     call    $AMIS$ATTEMPT_POPUP
  235.     mov    al,AMIS_POPUP_WILLDO    ; can't pop up now, will do so when able
  236.     cmp    $AMIS$WANT_POPUP,1    ; did we manage to pop up?
  237.     je    API_popup_done
  238.     mov    al,AMIS_SUCCESSFUL    ; successful
  239.     xor    bx,bx            ; no return code
  240. API_popup_done:
  241.     ret
  242. API_popup endp
  243.     ENDM
  244.  
  245. ;-----------------------------------------------------------------------
  246.  
  247. DEFAULT_API_REMOVE MACRO
  248. API_remove proc near
  249.     ASSUME    DS:NOTHING,ES:NOTHING,SS:NOTHING
  250.     inc    $AMIS$WANT_SHUTDOWN
  251.     inc    $AMIS$WANT_POPUP
  252.     extrn    $AMIS$TRY_POPUP:near
  253.     call    $AMIS$TRY_POPUP
  254.     mov    al,0
  255.     xchg    al,$AMIS$WANT_SHUTDOWN    ; get and clear shutdown flag
  256.     cmp    al,0            ; if no longer set, shutdown successful
  257.     je    remov_successful
  258.     dec    $AMIS$WANT_POPUP    ; clear popup request
  259.     mov    al,AMIS_UNINST_TRYLATER    ; can't remove at this time
  260.     ret
  261. remov_successful:
  262.     mov    al,AMIS_UNINST_SAFE_OFF ; no resident remover, now disabled
  263.     mov    bx,0            ; seg of block to free (will be patched)
  264. ALTMPX$PSP equ word ptr ($-2)        ; magic name of word to be patched with
  265.                     ; actual memory block segment by TSR
  266.                     ; installation code
  267.     ret
  268. API_remove endp
  269.     ENDM
  270.  
  271. ;-----------------------------------------------------------------------
  272.  
  273. .LIST
  274.